home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / hf^k-1.dms / in.adf / Source.Lha / Startup-Code / startup.asm < prev   
Encoding:
Assembly Source File  |  1996-02-23  |  2.0 KB  |  112 lines

  1.  
  2. ; StormC Startupcode
  3. ; $VER StormC Startupcode 1.05 (21.02.95)
  4.  
  5. ; Copyright HAAGE & PARTNER Computer GmbH
  6.  
  7. ; datamodel: FAR
  8. ; codemodel: FAR
  9.  
  10. ; This is a minimal startup code. The "normal" functionality (open 
  11. ; dos.library, build argc/argv etc) is done by other functions from
  12. ; storm.lib
  13.  
  14.  
  15.     XDEF _exit
  16.     XDEF abort__STANDARD
  17.     XDEF _SysBase
  18.     
  19.     XREF _InitModules
  20.     XREF _CleanupModules
  21.     XREF main_
  22.     XREF wbmain__P09WBStartup
  23.     
  24.     TTL "FAR"
  25.     
  26. Forbid        = -132
  27. GetMsg        = -372
  28. ReplyMsg    = -378
  29. WaitPort    = -384
  30.  
  31.     SECTION "startup",CODE
  32.     
  33.     move.l 4.w,a6
  34.     move.l a6,_SysBase
  35.     move.l a7,returnAddress ; Save stack pointer for exit and abort
  36.  
  37.     move.l $114(a6),a1      ; ThisTask
  38.     tst.l $AC(a1)
  39.     bne .cli
  40.     
  41.     ; Run from Workbench
  42.     lea $5C(a1),a0
  43.     move.l a0,-(a7)
  44.     jsr WaitPort(a6)
  45.     move.l (a7)+,a0
  46.     jsr GetMsg(a6)
  47.     move.l d0,StartupMessage
  48.     jsr _InitModules         ; Call INIT functions
  49.     move.l StartupMessage,-(a7)
  50.     jsr wbmain__P09WBStartup ; Call WB main function (C++ version)
  51.     addq.l #4,a7
  52.     jsr _CleanupModules      ; Call EXIT functions
  53.     move.l _SysBase,a6
  54.     jsr Forbid(a6)
  55.     move.l StartupMessage,a1
  56.     jsr ReplyMsg(a6)
  57.     moveq #0,d0
  58.     rts
  59.  
  60. .cli
  61.     move.l a0,-(a7)
  62.     move.l d0,-(a7)
  63.     jsr _InitModules          ; Call INIT functions
  64.     jsr main_                 ; Call main function (C++ version)
  65.     addq.l #8,a7
  66.     move.l d0,-(a7)
  67.     jsr _CleanupModules       ; Call EXIT functions
  68.     move.l (a7)+,d0
  69.     rts
  70.     
  71.     SECTION "exit",CODE
  72.     
  73. _exit
  74.     move.l 4(a7),d0
  75.     move.l returnAddress,a7   ; Restore stack pointer
  76.     move.l d0,-(a7)
  77.     jsr _CleanupModules       ; Call EXIT functions
  78.     move.l     StartupMessage,d2
  79.     beq .nowb
  80.     move.l _SysBase,a6
  81.     jsr Forbid(a6)
  82.     move.l d2,a1
  83.     jsr ReplyMsg(a6)
  84. .nowb
  85.     move.l (a7)+,d0
  86.     rts
  87.  
  88.     SECTION "abort_STANDARD",CODE
  89.  
  90. abort__STANDARD
  91.     move.l returnAddress,a7    ; Restore stack pointer
  92.     move.l     StartupMessage,d2
  93.     beq .nowb
  94.     move.l _SysBase,a6
  95.     jsr Forbid(a6)
  96.     move.l d2,a1
  97.     jsr ReplyMsg(a6)
  98. .nowb
  99.     moveq #3,d0
  100.     rts
  101.  
  102.     SECTION "startupd",DATA
  103.  
  104. _SysBase
  105.     dc.l 0
  106. returnAddress
  107.     dc.l 0
  108. StartupMessage
  109.     dc.l 0
  110.  
  111.     END
  112.